//package com.csii.adhoc.JdbcTemplate;
//
//import org.springframework.jdbc.core.JdbcTemplate;
//
//import java.sql.Array;
//import java.sql.SQLException;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Map;
//
//
//public class AlterTable {
//    public static void main(String[] args) throws SQLException {
//        JdbcTemplateFactory factory = new JdbcTemplateFactory(1);
//        DataSourceConfig config = new DataSourceConfig();
//        config.setUrl("jdbc:oracle:thin:@172.16.57.145:1521:kfdb")
//                .setUsername("dw3").setPasswd("dw3")
//                .setDriverClass("oracle.jdbc.driver.OracleDriver")
//                .setConnId("111");
//        JdbcTemplate jdbcTemplate = factory.getBean(config);
//        List<String> tbales = getTbales();
//        String getAllCol = "select  t.nullable,t.column_name from user_tab_columns  t where  t.table_name = '%s'";
//        String getKey = "select cu.COLUMN_NAME \n" +
//                "from user_cons_columns cu, user_constraints au \n" +
//                "where cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and au.table_name = '%s'";
//        ArrayList<String> res = new ArrayList<>();
//        tbales.forEach(t->{
//            String getCols = String.format(getAllCol,t);
//            List<Map<String, Object>> maps = jdbcTemplate.queryForList(getCols);
//            ArrayList<Col> cols = new ArrayList<>();
//            maps.forEach(map->{
//                Col col = new Col();
//                col.setColumnName(String.valueOf(map.get("COLUMN_NAME")));
//                col.setNullable(String.valueOf(map.get("NULLABLE")));
//                col.setTable(t);
//                cols.add(col);
//            });
//
//            String getKeys = String.format(getKey,t);
//            List<Map<String, Object>> maps1 = jdbcTemplate.queryForList(getKeys);
//            if (maps1!=null){
//                maps1.forEach(x->{
//                    String column_name = String.valueOf(x.get("COLUMN_NAME"));
//                    cols.forEach(y->{
//                        if (y.getColumnName().equals(column_name)){
//                            y.setIsKey(true);
//                        }
//                    });
//                });
//            }
//            List<Col> alterCol = new ArrayList();
//            cols.forEach(x->{
//                if ("N".equals(x.getNullable()) && !x.getIsKey()){
//                    alterCol.add(x);
//                }
//            });
//            alterCol.forEach(x->{
//                String alterSql = getAlterSql(x);
//                res.add(alterSql);
//            });
//            System.out.println(res);
//        });
//
//    }
//
//    private static String getAlterSql(Col col){
//        String s = "alter table %s modify %s null;";
//        String format = String.format(s, col.getTable(), col.getColumnName());
//        return format;
//    }
//    private static List<String> getTbales(){
//        String s = "DPS_DEP_AGRDP_INFO\n" +
//                "LOAN_CIF_CORP_STOCK\n" +
//                "LOAN_CIF_CORP_GDINFO\n" +
//                "LNS_LN_REPAY_ACCT\n" +
//                "DPS_DEP_ACCT_BAL_HPN_DETL\n" +
//                "LOAN_PROD_BASE\n" +
//                "LNS_LN_ACTP_ACCT\n" +
//                "LOAN_CIF_CORP_INF\n" +
//                "LOAN_BILL_INFO\n" +
//                "LOAN_LN_DUE\n" +
//                "LOAN_RPT_XD_BILL\n" +
//                "LOAN_AC_DISC_REG\n" +
//                "LNS_LN_DIS_ACCT_D\n" +
//                "LOAN_LN_PACT\n" +
//                "LOAN_AC_ADVANCED_REG\n" +
//                "LOAN_AC_LN_PM_LOG\n" +
//                "DPS_CF_AML_BASIC_INFO\n" +
//                "DPS_CF_CUST_ADDR\n" +
//                "DPS_CF_CUST_CUST_RELT\n" +
//                "DPS_CF_CORPOR_CUST\n" +
//                "DPS_CF_INDV_CUST\n" +
//                "DPS_CF_OLD_ENG_NAME\n" +
//                "DPS_CF_CUST_CONTR_INFO\n" +
//                "DPS_CF_CUST_RELT_LVL\n" +
//                "DPS_CF_CUST_CERT_INFO\n" +
//                "DPS_CF_ITRB_CUST\n" +
//                "DPS_CF_CUST_COMPANY\n" +
//                "DPS_DEP_ACCT_ACCRUE\n" +
//                "DPS_DEP_PROD_BIZACT_TYPE\n" +
//                "LNS_LN_PROD\n" +
//                "DPS_DEP_ACCT_INTRT_CHGD\n" +
//                "DPS_DEP_ACCTNO_ANLS\n" +
//                "DPS_DEP_ACCT_PRTCT_RELT_DEF\n" +
//                "DPS_IT_BASIC_INT_RATE\n" +
//                "LNS_LN_ACCT_BAL\n" +
//                "PTELLER_PTL_TRNLOG\n" +
//                "LOAN_AC_LN_REG\n" +
//                "DPS_CE_CUST_VOU_EVT\n" +
//                "DPS_PUB_BOOK_PARA\n" +
//                "DPS_PUB_AUTH_CTRL\n" +
//                "DPS_PUB_ANALYSIS_DETL\n" +
//                "DPS_BR_BRCH\n" +
//                "DPS_DEP_PROD\n" +
//                "LNS_LN_CUST_TRANS_DETL\n" +
//                "LNS_LN_EXT_RGSTNT\n" +
//                "DPS_DEP_ACCT_SPLMT\n" +
//                "DPS_EM_CHRG_REG\n" +
//                "LNS_LN_PROD_ACTG_CATG\n" +
//                "DPS_DEP_ACCTNO_SELNUM_REG\n" +
//                "DPS_DEP_ACCT_BAL\n" +
//                "DPS_PUB_ANALYSIS_HEAD_DETL\n" +
//                "DPS_DEP_CUSTAC\n" +
//                "DPS_CE_CUST_VOU\n" +
//                "LNS_LN_ACCT\n" +
//                "DPS_DEP_ACCT_INFO\n" +
//                "DPS_PUB_TRAN_LOG\n" +
//                "DPS_IT_ACTUAL_INT_RATE\n" +
//                "LNS_LN_ACCTS_DETL\n" +
//                "NC_NC_SUBJ_DICT\n" +
//                "NC_NC_SUBJ_BAL\n" +
//                "LOAN_APPLY_BASE\n" +
//                "LOAN_IMPAIR_PROV_DETAIL\n" +
//                "TRZ_SYS_LOG\n" +
//                "CBS_CBP_USR_SWF\n" +
//                "YQ_ST_OPERATION_LOG\n" +
//                "SSO_T_USER_LOG\n" +
//                "SSO_T_SSO_USER\n" +
//                "SSO_T_SSO_ROLE\n" +
//                "SSO_T_SSO_DEPARTMENT\n" +
//                "ACS_GL_BIZ_CD_PARA\n" +
//                "ACS_GL_BOOK_PARA\n" +
//                "DPS_DEP_PROD_ACCRUE_DEF\n" +
//                "LNS_LN_PROD_REACC\n" +
//                "DPS_DEP_PROD_NORM_CTRL\n" +
//                "LNS_LN_ACCT_DRAWDN\n" +
//                "LOAN_AC_LN_BAL_LOG\n" +
//                "LOAN_RATING_BASE\n" +
//                "LOAN_AC_LN_MST\n" +
//                "LOAN_APPLY_DUE\n" +
//                "LOAN_ASSURE_INF\n" +
//                "LOAN_GUAR_COMP\n" +
//                "LOAN_AC_CVRG_REG\n" +
//                "LOAN_RISK_FIVE_CHANGE\n" +
//                "LOAN_CIF_BASE\n" +
//                "LOAN_LN_PACT_PLUS\n" +
//                "LOAN_QUOTA_INFO\n" +
//                "LOAN_CIF_GROUP_MEM\n" +
//                "LOAN_APPRO_BASE\n" +
//                "DPS_IT_INT_RATE_CD_DEF\n" +
//                "LNS_LN_ACCT_REPAY\n" +
//                "DPS_TM_SA_ACCT\n" +
//                "LNS_LN_OBS_ACCT\n" +
//                "LNS_LN_PRVSN_PRVS_DETL\n" +
//                "DPS_TM_SA_BOOK_DETL\n" +
//                "DPS_TM_SA_ACCT_SEQNO_PARA\n" +
//                "LNS_LN_OBS_DETL\n" +
//                "LNS_LN_RECV\n" +
//                "DPS_DEP_ACCT_INT_DETL\n" +
//                "DPS_TM_DI_DMND_ACCT\n" +
//                "TRZ_AFTER_VOTE_FIVE_GRADE\n" +
//                "TRZ_TB_PRO_HOLD_BOND\n" +
//                "DPS_TM_DI_FIXD_ACCT\n" +
//                "TRZ_TB_DUEBANKS_CONTRACT\n" +
//                "TRZ_TB_CORPORATE_FORM\n" +
//                "TRZ_PRODUCT_INFO\n" +
//                "TRZ_SINGLE_CREDIT_RESULT\n" +
//                "TRZ_TB_INVEST_PLAN\n" +
//                "DPS_CF_STAFF\n" +
//                "LOAN_CIF_IMP_EVENT\n" +
//                "DPS_CF_CUS";
//        String[] split = s.split("\n");
//        return Arrays.asList(split);
//    }
//}
